package com.neusoft.adminweb.service.impl;

import com.neusoft.adminweb.dao.DutyRecordDao;
import com.neusoft.adminweb.entity.DutyRecord;
import com.neusoft.adminweb.service.DutyRecordService;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;
import java.util.List;

/**
 * (DutyRecord)表服务实现类
 *
 * @author makejava
 * @since 2020-11-09 10:29:14
 */
@Service("dutyRecordService")
public class DutyRecordServiceImpl implements DutyRecordService {
    @Resource
    private DutyRecordDao dutyRecordDao;

    /**
     * 通过ID查询单条数据
     *
     * @param id 主键
     * @return 实例对象
     */
    @Override
    public DutyRecord queryById(Integer id) {
        return this.dutyRecordDao.queryById(id);
    }

    /**
     * 查询多条数据
     *
     * @param offset 查询起始位置
     * @param limit  查询条数
     * @return 对象列表
     */
    @Override
    public List<DutyRecord> queryAllByLimit(int offset, int limit) {
        return this.dutyRecordDao.queryAllByLimit(offset, limit);
    }

    /**
     * 新增数据
     *
     * @param dutyRecord 实例对象
     * @return 实例对象
     */
    @Override
    public DutyRecord insert(DutyRecord dutyRecord) {
        this.dutyRecordDao.insert(dutyRecord);
        return dutyRecord;
    }

    /**
     * 修改数据
     *
     * @param dutyRecord 实例对象
     * @return 实例对象
     */
    @Override
    public DutyRecord update(DutyRecord dutyRecord) {
        this.dutyRecordDao.update(dutyRecord);
        return this.queryById(dutyRecord.getId());
    }

    /**
     * 通过主键删除数据
     *
     * @param id 主键
     * @return 是否成功
     */
    @Override
    public boolean deleteById(Integer id) {
        return this.dutyRecordDao.deleteById(id) > 0;
    }
}